package com.allwees.support.payment.oceanpay;

import com.allwees.support.payment.model.RefundInfo;
import com.allwees.support.payment.oceanpay.client.OceanpayRequestClient;
import com.allwees.support.payment.oceanpay.config.OceanpayProperties;
import com.allwees.support.payment.oceanpay.dto.RefundApplyRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Daniel
 * @version 1.0.0
 * @since 2020/12/6 16:58
 */
@Component
public class CreditCardStrategy {

    @Autowired
    private static OceanpayProperties properties = new OceanpayProperties();

    public static void refund(RefundInfo refundInfo) {
        RefundApplyRequest request = new RefundApplyRequest();
        request.setAccount(properties.getAccount());
        request.setTerminal(properties.getTerminal());
        request.setRefund_amount(refundInfo.getAmt().toPlainString());
//        request.setRefund_description("رد المستخدم بشكل استباقي");
        request.setRefund_description("User proactively refund");
        request.setPayment_id(refundInfo.getPaymentNo());
        OceanpayRequestClient.sendRefundApplyRequest(request,properties.getSecureCode());
    }
}
